package com.bistu.xiong.tulingrobotchat;

import android.content.Context;
import android.content.Intent;

import com.bistu.xiong.common.app.Activity;
import com.bistu.xiong.factory.persistence.Account;
import com.bistu.xiong.tulingrobotchat.activities.AccountActivity;
import com.bistu.xiong.tulingrobotchat.activities.MainActivity;
import com.bistu.xiong.tulingrobotchat.activities.UpdateUserActivity;
import com.bistu.xiong.tulingrobotchat.frags.assist.PermissionsFragment;

public class LaunchActivity extends Activity implements PermissionsFragment.MyPermissionsCallback{

    /**
     * LaunchActivity 显示的入口
     * @param context 上下文
     */
    public static void show(Context context) {
        context.startActivity(new Intent(context, LaunchActivity.class));
    }

    @Override
    protected int getCountentLayoutId() {
        return R.layout.activity_launch;
    }

    @Override
    protected void initData() {
        super.initData();
        //判断是否拥有足够的权限 没有将会显示申请权限界面
        if (PermissionsFragment.haveAll(this, getSupportFragmentManager())) {
            skip();
        }
    }

    public void skip(){
        // 判断用户是否已登录
        if(Account.isLogin()){
            MainActivity.show(this);
        }else{
            //未登录下跳转登录界面
            AccountActivity.show(this);
        }
        finish();
    }

    @Override
    public void afterGetPermissions() {
        skip();
    }
}
